-
Notifications
You must be signed in to change notification settings - Fork 578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated semantics for atproto labelers header #2292
Conversation
|
||
const makeResHeaders = (res: Response): Record<string, string> => { | ||
const headers = RES_HEADERS_TO_FORWARD.reduce((acc, cur) => { | ||
acc[cur] = res.headers.get(cur) ?? undefined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible for headers.get(cur)
to be null
? That is the only case I can imagine the ?? undefined
having an effect. If we want/need to deal with empty strings we could make this || undefined
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah the return type for headers.get()
is string | null
👍
packages/bsky/src/util.ts
Outdated
if (labeler.length === 0) { | ||
continue | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would technically make the header invalid. If we want to pull in a parser, parseList()
from structured-headers does what we need here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah nice, that sounds like it's probably worth it 👍
My thinking here was specificlaly for the case of an empty string val ie atproto-accept-labelers:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! We could handle malformed headers by erroring or treating it as though it's empty and assuming the default.
It may be a bit much for now, but it's allowed to combined header values for lists if the header appears multiple times (see here). For example:
I could see us just punting on it for now but figured it's worth a note! |
Updated semantics for atproto labelers headers